package com.iraeta.controller;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.iraeta.api.HikAlarmApi;
import com.iraeta.api.HikCameraApi;
import com.iraeta.api.HikRegionApi;
import com.iraeta.common.AuthAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/test")
public class TestController extends BaseController{
    @Autowired
    HikRegionApi hikRegionApi;
    @Autowired
    HikAlarmApi hikAlarmApi;
    @Autowired
    HikCameraApi hikCameraApi;

    @RequestMapping("/test1")
    @AuthAccess
    public String test1() throws Exception{
        return hikRegionApi.getRootRegion();
    }
    @RequestMapping("/test2")
    @AuthAccess
    public String test2() throws Exception{
        return hikRegionApi.getChildrenRegion("root000000");
    }
    @RequestMapping("/test3")
    @AuthAccess
    public String test3() throws Exception{
        Date startDate = DateUtil.parseDate("2024-01-08 14:00:00");
        Date endDate = DateUtil.parseDate("2024-01-08 15:00:00");
        return hikAlarmApi.getAlarmInfo(startDate, endDate);
    }
    @RequestMapping("/test4")
    @AuthAccess
    public String test4() throws Exception{
        return JSON.toJSONString( hikCameraApi.getCamera("root000000"));
    }
    @RequestMapping("/test5")
    @AuthAccess
    public String test5() throws Exception{
        return hikCameraApi.getCameraPreviewHls("1310035691c748889a1b80891270a1ed");
    }
    @RequestMapping("/test6")
    @AuthAccess
    public String test6() throws Exception{
        return hikCameraApi.getCameraPreviewRtmp("1310035691c748889a1b80891270a1ed");
    }
}
